import { createRouter, createWebHistory } from 'vue-router';
import { routesList } from './modules/routeList';
//@ts-expect-error
import nprogress from 'nprogress';

// 创建路由对象
const router = createRouter({
  history: createWebHistory(),
  routes: routesList
});

// 进度条配置
nprogress.configure({
  easing: 'ease',
  speed: 500,
  showSpinner: true,
  trickle: true
});
// 路由前置守卫
router.beforeEach((to, form, next) => {
  // 开启进度条
  nprogress.start();
  next();
});

// 路由后置守卫
router.afterEach((to, form) => {
  // 关闭进度条
  console.log(to, form);

  nprogress.done();
});

export default router;
